package com.dcy.znoa.service.attendance.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.dcy.znoa.common.util.pojo.JsonForList;
import com.dcy.znoa.controller.attendance.model.attUserRule.AURBindModel;
import com.dcy.znoa.controller.attendance.model.attUserRule.SelectAURBindModel;
import com.dcy.znoa.dao.attendance.AttUserRuleDao;
import com.dcy.znoa.domain.Oper;
import com.dcy.znoa.domain.attendance.AttUserRule;
import com.dcy.znoa.service.attendance.AttUserRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

//这个表暂时不用 service要用
@Service
public class AttUserRuleServiceImpl implements AttUserRuleService {
    @Autowired
    AttUserRuleDao attUserRuleDao;


    @Override
    public Integer insert(AttUserRule attUserRule) {
        return null;
    }

    @Override
    public Integer updateById(AttUserRule attUserRule) {
        return null;
    }

    @Transactional
    @Override
    public Integer addBatch(AURBindModel model) {
        String strs = model.getOperIdsStr();
        int ids[] = AURBindModel.String2Ints(strs);
        model.setIds(ids);
        return attUserRuleDao.addBatch(model);
    }

    @Transactional
    @Override
    public Integer delBatch(AURBindModel model) {
        String strs = model.getOperIdsStr();
        int ids[] = AURBindModel.String2Ints(strs);
        model.setIds(ids);
        return attUserRuleDao.delBatch(model);
    }

    @Override
    public JsonForList selectBind(SelectAURBindModel model) {
        Page page = new Page(model.getPageNum(), model.getPageSize());
        List<Oper> list = attUserRuleDao.selectBind(model, page);
        return new JsonForList(list, page.getTotal());
    }

    @Override
    public JsonForList selectUnBind(SelectAURBindModel model) {
        Page page = new Page(model.getPageNum(), model.getPageSize());
//        List<Oper> list = attUserRuleDao.selectUnBind(model, page);
        List<Oper> list = attUserRuleDao.selectUnBind(model, page);
        return new JsonForList(list, page.getTotal());
//        return attUserRuleDao.selectUnBind(model);
    }
}
